package day10;

import java.util.ArrayList;
import static java.util.Comparator.*;
import java.util.List;

public class Demo02 {
    public static void main(String[] args) {
        /*
         * 排序方法
         * comparing 正在比较
         * then 然后
         * reversed 反转
         */
        List<Person> list = new ArrayList<>();
        list.add(new Person(1, "熊大", 1.1, 200));
        list.add(new Person(2, "熊二", 1.2, 200));
        list.add(new Person(3, "光头强", 1.7, 100));
        list.add(new Person(4, "范传奇", 1.8, 110));
        list.sort(comparingInt(Person::getWeight)
                .thenComparingDouble(Person::getHight)
                .reversed());
        list.forEach(System.out::println);
    }
}
class Person{
    private int id;
    private String name;
    private double hight;
    private int weight;

    public Person() {

    }

    public Person(int id, String name, double hight, int weight) {
        this.id = id;
        this.name = name;
        this.hight = hight;
        this.weight = weight;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getHight() {
        return hight;
    }

    public void setHight(double hight) {
        this.hight = hight;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", hight=" + hight +
                ", weight=" + weight +
                '}';
    }
}
